import { Module } from '@nestjs/common';
import { UploadService } from './upload.service';
import { UploadController } from './upload.controller';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from "multer"
import { join, extname } from "path"
@Module({
  imports: [MulterModule.register({
    storage: diskStorage({
      destination: 'public/images',
      filename: (req, file, cb) => {
        const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
        return cb(null, `${randomName}${extname(file.originalname)}`)
      }
    })
  })],
  controllers: [UploadController],
  providers: [UploadService],
})
export class UploadModule { }
